<template>
  <view class="finance">
    <mineNavbar :styleData="styleData" />

    <scroll-view class="scroll" scroll-y>
      <!-- <view class="catetory">
        <view v-for="item in workTypeArr" v-key="item" @click="changeWorkType(item)" :key="item">
          <view :class="workTypeValue === item ? 'active' : 'common'">{{ item }}</view>
          <image src="../../../../static/images/recruit/wan.png" mode="" v-if="workTypeValue === item" />
        </view>
      </view> -->
      <view class="contain">
        <view class="t_invite">薪马马邀请二维码</view>
        <view class="t_bg">
          <view class="b_text">零工就业招聘驿站</view>
          <image :src="codeInfo.enterpriseCodeUrl" />
          <view class="b_weixin">
            <image src="http://wangxinbao.oss-cn-beijing.aliyuncs.com/2024/04/27/b9a8240233204154b5200804327ee853.png" />
            <text>微信扫描二维码即可使用</text>
          </view>
          <view>{{ codeInfo.storeName }}</view>
        </view>
        <view class="t_save" @click="handleSave(codeInfo.enterpriseCodeUrl)">保存邀请二维码</view>
      </view>
      <!-- <view class="contain" v-else>
        <view class="t_invite">邀请用户二维码</view>
        <view class="t_bg">
          <view class="b_text">零工就业招聘驿站</view>
          <image :src="codeInfo.userCodeUrl" />
          <view class="b_weixin">
            <image src="http://wangxinbao.oss-cn-beijing.aliyuncs.com/2024/04/27/b9a8240233204154b5200804327ee853.png" />
            <text>微信扫描二维码即可使用</text>
          </view>
          <view>{{ codeInfo.storeName }}</view>
        </view>
        <view class="t_save" @click="handleSave(codeInfo.userCodeUrl)">保存邀请二维码</view>
      </view> -->
    </scroll-view>
  </view>
</template>
 
<script>

export default {
  components: {},
  data() {
    return {
      styleData: {
        show: true,
        tabbarText: "门店二维码",
      },
      workTypeArr: ['邀请企业', '邀请用户'],
      workTypeValue: '邀请企业',
      itemActive: "全部",
      codeInfo: {

      }
    };
  },
  computed: {},
  // 监控data中的数据变化
  watch: {},
  onLoad(options) { },
  onShow() {
    this.codeInfo = JSON.parse(uni.getStorageSync('codeInfo')) ?? ''
  },
  onReady() { },
  computed: {
  },
  methods: {
    // 切换类型
    changeWorkType(e) {
      this.workTypeValue = e
    },
    // 保存二维码
    handleSave(url) {
      uni.downloadFile({
        url,
        success: ({ tempFilePath, statusCode }) => {
          console.log(tempFilePath);
          uni.saveImageToPhotosAlbum({
            // 这里不支持保存网络图片，改成返回的地址即可
            filePath: tempFilePath,
            success: function () {
              uni.showToast({
                title: '保存成功'
              })
            },
            fail: function () {
              uni.showToast({
                title: '保存失败',
                icon: "error"
              })
            }
          });
        },
        fail: (error) => {
          uni.showToast({
            title: '保存失败',
            icon: "error"
          })
        }
      })
    }
  },
};
</script>
<style lang="scss" scoped>
.finance {
  height: 100vh;
  background-color: #f9f9f9;
  display: flex;
  flex-direction: column;

  .scroll {
    flex: 1;
    width: 750rpx;
    display: flex;
    flex-direction: column;
    align-items: center;

    .catetory {
      width: 100%;
      height: 120rpx;
      display: flex;
      justify-content: space-around;

      >view {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;

        .active {
          font-weight: 900;
          font-size: 32rpx;
          color: #000;
        }
      }

      image {
        width: 35rpx;
        height: 6px;
        margin-top: 5px;
      }
    }

    .contain {
      display: flex;
      flex-direction: column;
      align-items: center;

      .t_invite {
        font-size: 40rpx;
        color: #000000e0;
        margin: 30rpx 0;
      }

      .t_bg {
        width: 668rpx;
        height: 800rpx;
        background: url('http://wangxinbao.oss-cn-beijing.aliyuncs.com/2024/04/07/25f63910227541e7879a2c5f34b0a1c0.png');
        background-size: cover;
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 32rpx;
        color: #000000e0;

        .b_text {
          margin-top: 180rpx;
          font-size: 32rpx;
          color: #00000073;
        }

        >image {
          width: 234rpx;
          height: 234rpx;
          margin-top: 60rpx;
          margin-bottom: 20rpx;
        }

        .b_weixin {
          display: flex;
          align-items: center;
          font-size: 22rpx;
          color: #00000073;
          margin-bottom: 100rpx;

          image {
            width: 32rpx;
            height: 32rpx;
            margin-right: 10rpx;
          }
        }
      }

      .t_save {
        font-size: 28rpx;
        color: #317ED0;
        margin-top: 30rpx;
      }
    }
  }
}
</style>
 